﻿// JScript 文件

//创建TEXT元素
function createTexts(nameArray)
{
    var textArray = new Array();
    
    for(i = 0; i < nameArray.length; i++)
    {
        textArray[i] = document.createElement("input");
        textArray[i].type = "text";
        textArray[i].id = nameArray[i];
//        $(textArray[i]).width(180); 
//        textArray[i].style.width = 60;
        //checkboxArray[i].className = clsName;
    }
    return textArray;
}    
//============================ljy加创建文本框，双参数======================== 
function createTextsd(nameArray,value)
{
    var textArray = new Array();
    
    for(i = 0; i < nameArray.length; i++)
    {
        textArray[i] = document.createElement("input");
        textArray[i].type = "text";
        textArray[i].id = nameArray[i];
        textArray[i].value=value;
        
//        $(textArray[i]).width(180); 
//        textArray[i].style.width = 60;
        //checkboxArray[i].className = clsName;
    }
    return textArray;
}   
//=========================================================================


//创建button元素
function createButtons(nameArray,clsName)
{
    var button;// = new Array();
    
    if(nameArray.length == 1)
    {
        button = document.createElement("input");
        button.type = "button";
        button.value = nameArray[0];
        button.className = clsName;
    }
    else
    {
        button = new Array();
        for(i = 0; i < nameArray.length; i++)
        {
            button[i] = document.createElement("input");
            button[i].type = "button";
            button[i].value = nameArray[i];
            button[i].className = clsName;
        }
    }
    return button;
}

function createButtons(nameArray,idArray)
{
    var button;// = new Array();
    
    if(nameArray.length == 1)
    {
        button = document.createElement("input");
        button.type = "button";
        button.value = nameArray[0];
        button.id = idArray[0];
    }
    else
    {
        button = new Array();
        for(i = 0; i < nameArray.length; i++)
        {
            button[i] = document.createElement("input");
            button[i].type = "button";
            button[i].value = nameArray[i];
            button[i].id = idArray[i];
        }
    }
    return button;
}


//创建checkbox元素
function createCheckboxs(nameArray)
{
    var checkboxArray = new Array();
    
    for(i = 0; i < nameArray.length; i++)
    {
        checkboxArray[i] = document.createElement("input");
        checkboxArray[i].type = "checkbox";
        checkboxArray[i].id = nameArray[i];
        checkboxArray[i].checked = false;
        if (nameArray[i].length == 0)
        {
            checkboxArray[i].style.visibility = "hidden";
        }
        //checkboxArray[i].className = clsName;
    }
    return checkboxArray;
}

//创建radio元素
function createRadios(idArray,name,funcName)
{
    var radioArray = new Array();
    
    for (i = 0; i < idArray.length; i++)
    {
        radioArray[i] = document.createElement("input");
        radioArray[i].type = "radio";
        radioArray[i].id = idArray[i];
        radioArray[i].name = name;
        //$(radioArray[i]).bind("click",{id: nameArray[i]}, funcName);
        $(radioArray[i]).bind("click",{id: idArray[i]},function(event){
            for(var j = 0; j < idArray.length; j++)
            {
                $(radioArray[j]).attr("checked",false); 
        //                    $(eval("#" + radioArray[i].id)).checked = true;
            }
            eval($("#" + event.data.id)).attr("checked",true);
            
        });
    }
    return radioArray;

}

//创建文本节点
function createTextNode(nameArray)
{
    var labelArray = new Array();
    
    for (i = 0; i < nameArray.length; i++)
    {
        labelArray[i] = document.createTextNode(nameArray[i]);
    }
    return labelArray;
}

function createOptions(ValueArray,NameArray)
{
   
    var options = new Array();
    for(var i = 0; i < ValueArray.length; i++)
    {
        options[i] = document.createElement("option");
        options[i].value = ValueArray[i];
        options[i].text = NameArray[i];
    }
    return options;
}
